package updown.constant;

/**
 * <p>Title: ww.kaixin.downupservice.constant </p>
 * <p>Description:to-22-6-1: -  </p>
 *
 * @Author:jiangkaixin
 * @Date:2021/12/20
 * @Version: 1.0
 */
public class MsgConstant {

    public static final String send_down_msg = "发送下线请求";
    public static final String send_down_msg_fail = "发送 status=DOWN 失败，服务替换终止";
    public static final String send_down_msg_after_sleep = "发送 status=DOWN 成功，开始睡眠，默认 90s，等待缓存清除";
    public static final String ready_to_kill_15 = "睡眠结束，等待发送 kill -15 请求";
    public static final String kill_15_script_success = "kill -15 脚本执行成功，等待 下线执行完成，默认15s";
    public static final String kill_15_success = "kill -15 成功，EurekaServer 中已无此服务实例信息";
    public static final String kill_15_fail = "kill -15 失败，服务替换操作暂停。当前服务处于DOWN状态!!!: 1. 登录服务器 手动 kill -15; 2. 点击 Service List 选择DOWN 的服务，发送UP 请求，然后 kill -9，重启服务";
    public static final String kill_15_fail_msg = "kill -15 脚本执行失败，服务替换终止";
    public static final String kill_15_check_eureka_fail = "kill15 之后 30s，eureka 中还是能发现当前服务，服务替换终止";
    public static final String start_script_ready = "服务已下线，准备执行重启脚本";
    public static final String start_script_success = "执行服务启动脚本成功，睡眠等待";
    public static final String start_script_fail = "执行启动脚本失败，需要手动重启，服务替换终止";
    public static final String start_script_success_but_not_register_in_eureka_server = "脚本执行成功，但是在eureka server 中没有发现对应的服务，服务替换终止";
    public static final String start_script_success_but_not_register_in_eureka_server_fail = "脚本执行成功，但是在eureka server 中没有发现对应的服务，服务替换终止";
    public static final String start_to_notify_all_service_check = "检查 本地的discovery 缓存有无 重新注册的服务信息";
    public static final String start_to_notify_all_service = "服务启动成功，等待所有服务上都有重新注册的信息，等待90s";
    public static final String local_service_has_instance = "服务启动成功，并且本地，已经发现了新注册的服务实例信息，重新启动成功";
    public static final String local_service_has_instance_fail = "服务启动成功，但是本地未发现 对应的服务，再等待15s之后，再次检查";
    public static final String local_service_has_instance_after_retry_fail = "服务启动成功，再等待15s之后，本地还未发现，失败，停止替换，需人工介入，查看原因";
    public static final String local_service_has_instance_after_retry_success = "服务启动成功，再等待15s之后，本地发现服务，重启成功，准备执行下一个服务替换";
    public static final String ready_to_start_next = "服务启动成功，准备启动下一个服务";
    public static final String down_up_finish = "服务替换完成，耗时：";
    public static final String rollback_finish = "服务回滚替换完成，耗时：";


    public static final String down_to_local_start = "准备把jar包保存到本地";
    public static final String down_to_local_finish  = "服务已经保存到本地，path：";

    public static final String fail  = "fail";
    public static final String success  = "success";

    public static String getFailMsgByType(String type) {
        if (GeneralConstant.RETRY_TYPE_KILL15.equals(type)) {
            return kill_15_fail_msg;
        } else if (GeneralConstant.RETRY_TYPE_CHECK_CANCEL.equals(type)) {
            return kill_15_check_eureka_fail;
        } else if (GeneralConstant.RETRY_TYPE_SEND_DOWN.equals(type)) {
            return send_down_msg_fail;
        } else if (GeneralConstant.RETRY_TYPE_RESTART.equals(type)) {
            return start_script_fail;
        }else if(GeneralConstant.RETRY_TYPE_RE_REGISTER_EUREKA.equals(type)){
            return start_script_success_but_not_register_in_eureka_server_fail;
        }else if(GeneralConstant.RETRY_TYPE_CHECK_LOCAL.equals(type)){
            return local_service_has_instance_after_retry_fail;
        }
        return null;
    }
}
